/**
 * 
 */
package com.aq.actions;

/**
 * @author shl
 *
 */
import java.util.Collection;

import org.apache.commons.lang.StringUtils;

import com.aq.model.AqMessage;
import com.aq.model.AqNews;
import com.aq.service.IMessageService;
import com.aq.service.INewsService;
import com.hs.common.page.PageParam;
import com.hs.common.page.PageUtil;
import com.hs.core.action.AbstractAction;

public class MessageAction extends AbstractAction {
    
    private IMessageService messageService;  
    private AqMessage message; 
    
    protected Collection availableItems;
    protected String pageStr;
    protected String content;
    protected PageUtil pageUtil;  
    protected Long messageid;
    
    public String list() throws Exception {
    	
    	PageParam pageParam = new PageParam(this.getHttpServletRequest(),"listNews.action");
		String hql = " from AqMessage where 1=1";
		pageParam.setSearchSql(hql);
		pageUtil = messageService.getMessageList(pageParam);
		availableItems = pageUtil.getPageList();
		pageStr = pageUtil.getPageStr();
//		System.out.println("pageStr:" + pageStr);
        return SUCCESS;         
    }
    
    public String load() throws Exception {
    	String messageid = this.getHttpServletRequest().getParameter("messageid");
    	if(StringUtils.isNotEmpty(messageid)){
    		setMessageid(new Long(messageid));
    		this.message = (AqMessage)messageService.findByID(AqMessage.class, this.getMessageid());
    		 
    	} 
    	
        return SUCCESS;
    }
    
    public String save() throws Exception { 
    	 
    	if(null != message){ 
    		messageService.saveObject(message); 
    	}
        return SUCCESS;
    }
    
    public String delete() throws Exception {
       
        return SUCCESS;
    }     
    public Collection getAvailableItems() {
        return availableItems;
    }

	public IMessageService getMessageService() {
		return messageService;
	}

	public void setMessageService(IMessageService messageService) {
		this.messageService = messageService;
	}

	public AqMessage getMessage() {
		return message;
	}

	public void setMessage(AqMessage message) {
		this.message = message;
	}

	public String getPageStr() {
		return pageStr;
	}

	public void setPageStr(String pageStr) {
		this.pageStr = pageStr;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public PageUtil getPageUtil() {
		return pageUtil;
	}

	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}

	public Long getMessageid() {
		return messageid;
	}

	public void setMessageid(Long messageid) {
		this.messageid = messageid;
	}

	public void setAvailableItems(Collection availableItems) {
		this.availableItems = availableItems;
	}

   
    
    
}
